﻿<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" default-access="property" default-lazy="true" namespace="Cms.Domain" assembly="Cms.Domain">
  <class name="MasterTemplate" table="cmsMasterTemplate">
    <cache usage="read-write" />
    <id name="ID" unsaved-value="0" column="ID" type="System.Int32">
      <generator class="identity" />
    </id>
    <property name="Name" column="TemplateName" not-null="true" type="System.String" />
    <property name="Description" column="TemplateDescription" not-null="false" type="System.String" />
    <many-to-one name="Site" column="SiteID" not-null="true" />
    <many-to-one not-null="true" cascade="all" name="SourceCode" column="SourceCodeID" />
    <bag name="Content" inverse="true" cascade="all-delete-orphan" table="cmsMasterTemplateContent">
      <cache usage="read-write" />
      <key column="MasterTemplateID" />
      <one-to-many class="MasterTemplateContentLink" />
    </bag>
    <bag name="Pages" table="cmsPage" cascade="save-update">
      <cache usage="read-write" />
      <key column="MasterTemplateID" />
      <one-to-many class="Page" />
    </bag>
    <map name="ContentSets" table="cmsMasterTemplateContentSet" inverse="true" cascade="all-delete-orphan">
      <cache usage="read-write" />
      <key column="MasterTemplateID" />
      <index column="LocaleID" type="System.Int32" />
      <one-to-many class="MasterTemplateContentSet" />
    </map>
    <bag name="AssociatedStylesheets" table="cmsMasterTemplateStylesheet" cascade="all-delete-orphan" inverse="true" order-by="SortIndex">
      <cache usage="read-write" />
      <key column="MasterTemplateID" />
      <one-to-many class="MasterTemplateStylesheet" />
    </bag>
    <bag name="DefaultDetailTemplates" table="cmsDetailTemplate" cascade="save-update" inverse="true">
      <cache usage="read-write" />
      <key column="DefaultMasterTemplateID" />
      <one-to-many class="DetailTemplate" />
    </bag>
    <bag name="Areas" table="cmsMasterTemplateArea">
      <cache usage="read-write" />
      <key column="MasterTemplateID" />
      <element column="AreaID" type="System.String" />
    </bag>
    <bag name="PageAreas" table="cmsMasterTemplatePageArea">
      <cache usage="read-write" />
      <key column="MasterTemplateID" />
      <element column="AreaID" type="System.String" />
    </bag>
  </class>
</hibernate-mapping>